package jface.util;

import jface.data.Company;
import jface.data.Person;

import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;

public class PersonTreeContentProvider implements ITreeContentProvider {
		
	public Object[] getElements(Object inputElement) {
		return ((Company) inputElement).getEmployees().toArray();
	}	

	public Object[] getChildren(Object parentElement) {
		return ((Person)parentElement).getEmployees().toArray();
	}

	public Object getParent(Object element) {
		return ((Person)element).getManager();
	}

	public boolean hasChildren(Object element) {
		return !((Person)element).getEmployees().isEmpty();
	}
	
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
	}

	public void dispose() {
	}

}
